<?php
/**
 * Created by PhpStorm.
 * User: tangchao
 * Date: 19-3-19
 * Time: 下午2:14
 */

namespace App\Model;


class Video extends Base
{
    public $tableName = "video";

    public function getVideoData($page = 1, $condition = ['status' => 1], $size =0){
        if (!empty($size)){
            $this->db->pageLimit = $size;
        }
        $this->db->where($condition);

        $res = $this->db->paginate($this->tableName,$page);

        $data = [
            'total_page' => $this->db->totalPages,
            'page_size' => $size,
            'count' => intval($this->db->totalCount),
            'lists' => $res,
        ];
        return $data;
    }

    public function getCache($condition = [], $size = 1000)
    {
        if (!empty($condition['cat_id'])){
            $this->db->where('cat_id',$condition['cat_id']);
        }
        $this->db->where('status',\Yaconf::get('easyswoole.status.normal'));
        if (!empty($size)){
            $this->db->pageLimit = $size;
        }

        $this->db->orderBy("id","desc");

        return $this->db->paginate($this->tableName,1);

    }


}